package interview.demo;

/**
 * @Author tu zy
 * @Date 2020/12/8 15:31
 * @Version 1.0
 */
public class ThreadDemo3 {
    public static void main (String[] args) throws InterruptedException{
        Thread t = new Thread(new Runnable() {
            @Override
            public void run() {
                while(true) {
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println("hello world");
                }
            }
        });
        t.start();

        try {
            Thread.sleep(10000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        t.interrupt();

    }
}
